'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	event.delete = 0	// 假删除
	  
	if (event.hasOwnProperty('_id')) {  // _id 属性存在
		const eventId = event._id
		delete event._id
		await db.collection('rx').where({ _id: eventId }).update(event)
		//返回数据给客户端
		return { data: { update: 1 }, code: 200, msg: 'ok.' }
		
	} else {  // _id 属性不存在
	    await db.collection('rx').add(event)
		//返回数据给客户端
		return { data: { update: 0 }, code: 200, msg: 'ok.' }
	}
	
	
};
